package com.xinlianshiye.im.response

class Page<T> {
    var totalCount: Int
    var totalPage = 0
    var currentPage = 0
    var start = 0
    var limit = 0
    var countNoRead = 0
    var bool: Boolean? = null
    var items: List<T>
    var `object`: Any? = null

    constructor(totalCount: Int, totalPage: Int, currentPage: Int, start: Int, limit: Int, items: List<T>) : super() {
        this.totalCount = totalCount
        this.totalPage = totalPage
        this.currentPage = currentPage
        this.start = start
        this.limit = limit
        this.items = items
    }

    constructor(items: List<T>, start: Int, limit: Int, totalCount: Int) {
        this.items = items
        this.start = start
        this.limit = limit
        this.totalCount = totalCount
        if (limit == 0) {
            totalPage = 1
            currentPage = 1
        } else {
            totalPage = totalCount / limit + if (totalCount % limit > 0) 1 else 0
            if (start >= limit) {
                if ((start + 1) % limit == 0) {
                    currentPage = start / limit
                } else {
                    currentPage = start / limit + 1
                }
            } else {
                currentPage = 1
            }
        }
    }

    constructor(items: List<T>, start: Int, limit: Int, totalCount: Int, bool: Boolean?) {
        this.items = items
        this.start = start
        this.limit = limit
        this.totalCount = totalCount
        this.bool = bool
        if (limit == 0) {
            totalPage = 1
            currentPage = 1
        } else {
            totalPage = totalCount / limit + if (totalCount % limit > 0) 1 else 0
            if (start >= limit) {
                if ((start + 1) % limit == 0) {
                    currentPage = start / limit
                } else {
                    currentPage = start / limit + 1
                }
            } else {
                currentPage = 1
            }
        }
    }

    constructor(items: List<T>, totalCount: Int, `object`: Any?) {
        this.items = items
        this.totalCount = totalCount
        this.`object` = `object`
    }

    constructor(items: List<T>, start: Int, limit: Int, totalCount: Int, countNoRead: Int) {
        this.items = items
        this.start = start
        this.limit = limit
        this.countNoRead = countNoRead
        this.totalCount = totalCount
        if (limit == 0) {
            totalPage = 1
            currentPage = 1
        } else {
            totalPage = totalCount / limit + if (totalCount % limit > 0) 1 else 0
            if (start >= limit) {
                if ((start + 1) % limit == 0) {
                    currentPage = start / limit
                } else {
                    currentPage = start / limit + 1
                }
            } else {
                currentPage = 1
            }
        }
    }
}